package ru.gosoplata.view 
{
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.IOErrorEvent;
	import flash.net.URLRequest;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import ru.gosoplata.model.TmpModel;
	import uicontrols.ButtonBase;
	/**
	 * ...
	 * @author 
	 */
	public class FooterPayBackText extends Sprite
	{
		private var _txtPayback:TextField=new TextField();
		private var _txt:TextField=new TextField();
		private var _skipBtn:ButtonBase = new ButtonBase("skip_pay", 0x444444);
		private var _bgPlane:Loader = new Loader();
		
		public function FooterPayBackText() 
		{
			var step:uint = 80;
			//var h:uint = 200;
			//x = step;
			//y = 1024 - h - step/2;
			
			//graphics.beginFill(0xff0000);
			//graphics.drawRoundRect(0, 0, 1280 - x * 2, h, 40, 40);
			_bgPlane.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function(e:IOErrorEvent):void { } );
			_bgPlane.load(new URLRequest(TmpModel.IMG_FOLDER + "/service/payback_sum.png"));
			_bgPlane.x = 315;
			_bgPlane.y = 180;
			addChild(_bgPlane);
			
			var tf:TextFormat = TmpModel.getTextFormat(40, 0xd93f3f, true);
			tf.align = "right";
			_txtPayback.defaultTextFormat = tf;
			_txtPayback.selectable = false;
			_txtPayback.x = 644 - 200+_bgPlane.x;
			_txtPayback.y = 198;
			//_txtPayback.background = true;
			//_txtPayback.backgroundColor = 0xffffff;
			_txtPayback.width = 100;
			
			//_txtPayback.text = "Использовать сдачу можно одним из предложеных ниже вариантов:";
			addChild(_txtPayback);
			
			tf = TmpModel.getTextFormat(24, 0x676767, false);
			tf.align = "center";
			_txt.defaultTextFormat = tf
			//_txt.autoSize = "center";
			_txt.width = 1280;
			_txt.selectable = false;
			_txt.y = 280;
			//_txt.border = true;
			_txt.text = "Использовать сдачу можно одним из предложеных ниже вариантов:";
			addChild(_txt);
			
			update(0);
			
			
			//_skipBtn.addTextIcon("NEXT", 30);
			//_skipBtn.addIcon(TmpModel.IMG_FOLDER + "/sdacha/sdacha_pozze.png");
			_skipBtn.addEventListener(ButtonBase.ON_PRESS_UI_BUTTON, onSkipBtn);
			_skipBtn.x = 1280-step-361-10;
			_skipBtn.y = 1024-20-186;
			addChild(_skipBtn);
		}
		
		private function onSkipBtn(e:Event):void 
		{
			TmpModel.tmpGlobalController.controllerSkipPayBack();
		}
		
		public function update(payBack:uint):void 
		{
			_txtPayback.htmlText = ""+ payBack ;
		}
		
	}

}